﻿@using System.Data
@using ZoomLa.Model
@{
    M_UserInfo mu = ViewBag.mu;
    DataTable banks = (DataTable)ViewBag.banks;
}
@functions{
    public string GetLastStr(string str, int num)
    {
        int count = 0;
        if (str.Length > num)
        {
            count = str.Length - num;
            str = str.Substring(count, num);
        }
        return str;
    }
}
@section head{
    <title>提现申请</title>
}
@section content{
    <div id="pageflag" data-nav="shop" data-ban="UserInfo"></div>
    <div class="container margin_t10">
        <ol class="breadcrumb">
            <li><a title="会员中心" href="@Url.Action("Default","")">会员中心</a></li>
            <li><a title="账户管理" href="@Url.Action("Userinfo","info")">账户管理</a></li>
            <li><a title="提现管理" href="@Url.Action("WithDrawLog","Money")">提现管理</a></li>
            <li class="active">申请提现 <a href="javascript:;" onclick="showconver();">[币值转换]</a> <a href="@Url.Action("UserBank","Money")">[银行账号管理]</a></li>
        </ol>
    </div>
    <div class="container">
        <form method="post" action="WithDraw_Add">
            <table class="table table-bordered table-hover table-striped">
                <tr><td class="td_m">现有金额：</td><td><span class="r_red">@mu.Purse.ToString("f2")</span></td></tr>
                <tr>
                    <td>提现金额：</td>
                    <td>
                        <input type="text" ID="Money_T" name="Money_T" class="form-control text_300 drawpri required number" />
                    </td>
                </tr>
                @if (banks != null && banks.Rows.Count > 0)
                {
                    <tr>
                        <td>银行账户：</td>
                        <td>
                            @foreach (DataRow dr in banks.Rows)
                            {
                                <label class="bank_lbl">
                                    <input type="radio" class="bankrad" onclick="setrad(this);" name="bankid" value="@dr["ID"]" data-pname="@dr["PeopleName"]" data-bname="@dr["BankName"]" data-remark="@dr["remark"]" data-bnum="@dr["CardNum"]" />
                                    <span class="pname">@dr["PeopleName"]</span>&nbsp;@dr["BankName"]（尾号：<span class="bnum">@GetLastStr(dr["CardNum"].ToString(), 4)</span>）
                                </label>
                            }
                        </td>
                    </tr>
                }
                <tbody>
                    <tr>
                        <td>开户人：</td>
                        <td>
                            <input type="text" class="form-control  text_300 required" ID="PName_T" name="PName_T" title="开户人姓名不能为空" /><span class="r_red">*</span>
                        </td>
                    </tr>
                    <tr>
                        <td>银行名称：</td>
                        <td>
                            <input type="text" class="form-control text_300 required" ID="Bank_T" name="Bank_T" title="银行名称不能为空" /><span class="r_red">*</span>
                        </td>
                    </tr>
                    <tr>
                        <td style="line-height:120px;">开户银行：</td>
                        <td>
                            <textarea ID="Remark_T" name="Remark_T" class="form-control text_300 required" Style="height: 120px;resize:none;"></textarea><span class="r_red">*</span>
                        </td>
                    </tr>
                    <tr>
                        <td>银行卡号：</td>
                        <td>
                            <input type="text" class="form-control text_300 required account" ID="Account_T" name="Account_T" maxlength="19" /><span class="r_red">*</span>
                        </td>
                    </tr>
                </tbody>
                <tr><td>二级密码</td><td>
                    @Html.Partial("Comp/ShortPassWord") <span class="r_red">*</span>
                    <div>
                        <label for="shortPwd_t" class="error" style="display: inline-block;"></label>
                    </div>
                    </td></tr>
                <tr>
                    <td></td>
                    <td>
                        @if (string.IsNullOrEmpty(mu.PayPassWord))
                        {
                            <div class="alert alert-warning">
                                你尚未设置二级密码,无法完成提现申请 <a href="/User/UserFunc/SetSecondPwd" class="btn btn-info marginl5">前往设置</a>
                            </div>
                           
                        }
                        else
                        {
                            <input type="submit" class="btn btn-primary" value="申请提现" />
                        }
                    </td>
                </tr>
            </table>
        </form>
    </div>
}
@section script{
    <style>
        .bank_lbl{font-weight:normal;margin:5px 0;vertical-align:middle; }
        .bank_lbl input { margin:0 5px;vertical-align:middle;  }
        .bank_lbl .pname,.bnum{font-weight:bolder;}
    </style>
    <script src="/JS/ZL_Regex.js"></script>
    <script src="/JS/Controls/ZL_Dialog.js"></script>
    <script>
        $(function () {
            $.validator.addMethod("drawpri", function (value, element) {
                if (ZL_Regex.isEmpty(value)) { return true; }
                var price = /^(?!0+(?:\.0+)?$)(?:[1-9]\d*|0)(?:\.\d{1,2})?$/;
                return this.optional(element) || (price.test(value));
            }, "提现金额必须大于零，最多保留两位小数!");
            $.validator.addMethod("account", function (value, element) {
                if (ZL_Regex.isEmpty(value)) { return true; }
                var account = /^(\d{16}|\d{19})$/;
                return this.optional(element) || (account.test(value));
            }, "请输入16或19位银行卡号");
            $("#shortPwd_t").addClass("required");
            $("form").validate();
            if ($(".bankrad").length > 0) { $(".bankrad").get(0).click(); }
        })
        function showconver() {
            ShowComDiag("/BU/Money/MoneyConver.aspx", "币值转换");
        }
        function setrad(rad) {
            var $rad = $(rad);
            $("#PName_T").val($rad.data("pname"));
            $("#Bank_T").val($rad.data("bname"));
            $("#Remark_T").val($rad.data("remark"));
            $("#Account_T").val($rad.data("bnum"));
        }
    </script>
}
